const path = require('path')

const proxyObj = {};
const targetURL = "http://localhost:8090";

// 跨域配置
proxyObj['/api'] = {
  ws: false,
  target: targetURL,    // 请求转发后的请求地址
  changeOrigin: true,
  pathRewrite: {
    '^/api': ''
  }
};

function resolve(dir) {
  return path.join(__dirname, dir)
}

module.exports = {
  configureWebpack: {
    resolve: {
      extensions: ['.js', '.vue', '.json', '.css'],
      alias: {
        '@': resolve('src'),
        'assets': '@/assets',
        'components': '@/components',
        'views': '@/views',
        'network': '@/network'
      },
    }
  },
  chainWebpack: config => {
    config.module
        .rule('svg')
        .exclude.add(resolve('src/assets/image/icons'))	//svg文件位置
        .end()
    config.module
        .rule('icons')
        .test(/\.svg$/)
        .include.add(resolve('src/assets/image/icons'))	//svg文件位置
        .end()
        .use('svg-sprite-loader')
        .loader('svg-sprite-loader')
        .options({
          symbolId: 'icon-[name]'
        })
        .end()
  },

  devServer: {
    host: "localhost",
    port: 8080,
    proxy: proxyObj
  }

};
